package com.huiztech.kaoqinji.service;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.huiztech.kaoqinji.AppConst;
import com.huiztech.kaoqinji.LocApplication;
import com.huiztech.kaoqinji.MainActivity;
import com.huiztech.kaoqinji.MainActivity.MyLocationListenner;
import com.huiztech.kaoqinji.model.LocationData;
import com.huiztech.kaoqinji.mvc.KaoqinBaseService;
import com.huiztech.kaoqinji.mvc.KaoqinController;

import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class TimeService extends KaoqinBaseService {

    public LocationClient mLocClient;
    //public MyLocationListenner myListener = new MyLocationListenner();
    private LocApplication locApplication;

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onStart(Intent intent, int startId) {
        super.onStart(intent, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mLocClient.stop();
    }

    @Override
    public void onCreate() {
        super.onCreate();
//        locApplication = (LocApplication) getApplication();
//        mLocClient = new LocationClient(this);
//        mLocClient.registerLocationListener(myListener);
        //sp = getSharedPreferences("user", MODE_PRIVATE);
      //  setLocationOption();
    }

//    private void setLocationOption() {
//        LocationClientOption option = new LocationClientOption();
//        option.setOpenGps(true);// 打开gps
//        option.setCoorType("bd09ll"); // 设置坐标类型
//        option.setAddrType("all");
//        option.setServiceName("com.baidu.location.service_v2.9");
//        option.setScanSpan(Integer.valueOf(controller.sp.getString("interval", AppConst.MOREN_INTERVAL)) * 60000); // 时间间隔
//        mLocClient.setLocOption(option);
//        mLocClient.start();
//    }
//
//    /**
//     * 定位监听函数
//     */
//    public class MyLocationListenner implements BDLocationListener {
//        @Override
//        public void onReceiveLocation(BDLocation location) {
//            if (location == null)
//                return;
//            if (location.getLocType() == BDLocation.TypeGpsLocation) {// GPS定位
//                controller.doVisitServer(location.getLatitude(), location.getLongitude());
//            } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {// 基站定位
//                controller.doVisitServer(location.getLatitude(), location.getLongitude());
//            }
//        }
//
//        public void onReceivePoi(BDLocation poiLocation) {
//            if (poiLocation == null) {
//                return;
//            }
//        }
//
//    }
}
